getwd()
paste(NULL, "hello")
# source the needed code
path_stem <- NULL    # if the current working directory is not spx_paper_code, change this line to
# supply the path to spx_paper_code since all other paths in this cose are relative to it
source(paste(path_stem, "jags_functions.R", sep = ""))
# source the needed code
path_stem <- NULL    # if the current working directory is not spx_paper_code, change this line to
# supply the path to spx_paper_code since all other paths in this cose are relative to it
source(paste(path_stem, "jags_functions.R", sep = ""))
source(paste(path_stem, "data_setup.R", sep = ""))
source(paste(path_stem, "models_list.R", sep = ""))
source(paste(path_stem, "two_stage.R", sep = ""))
# run K data sets in serial (from within a SLURM cluster job)
K <- 10
Sys.getenv('SLURM_JOB_NAME')
nchar(Sys.getenv('SLURM_JOB_NAME'))
scenario_from_SLURM <- nchar(Sys.getenv('SLURM_JOB_NAME')) > 0
# set simulation scenario info
scenario_from_SLURM <- nchar(Sys.getenv('SLURM_JOB_NAME')) > 0
if (scenario_from_SLURM) {     # parse info from SLURM job name
scenario_name <- Sys.getenv('SLURM_JOB_NAME')
scenario_num <- unlist(str_split(scenario_name, "_"))[2]  # assumes format like "scenario_2_low"
scenario_size <- unlist(str_split(scenario_name, "_"))[3]
if (scenario_size == "high") {
new_size <- 150
} else if (scenario_size == "low") {
new_size <- 80
}
is_strong <- str_detect(scenario_name, "strong")
} else {     # otherwise supply scenario info manually
scenario_num <- 1
new_size <- 80
is_strong <- FALSE
}
# run K data sets in serial (from within a SLURM cluster job)
K <- 10
# run K data sets in serial (from within a SLURM cluster job)
K <- 2
for (k in 1:K) {
# run trial/data set
trial <- one_rep_adaptive(scenario = scenario_num, strong_reg = is_strong, models_list = model_infos,
n_1 = round(new_size/2), n_2_max = new_size - round(new_size/2),
n_2_min = round(new_size*.25),
working_dir = path_stem)
# if the current working directory is not spx_paper_code, supply the path to spx_paper_code
# with the working_dir argument since other paths in the code are relative to it
# save the trial output in the working directory
scenario_name <- Sys.getenv('SLURM_JOB_NAME')
array_task_id <- Sys.getenv('SLURM_ARRAY_TASK_ID')
filename <- paste("trial", array_task_id, k, ".rds", sep = "_")
saveRDS(trial, filename)
}
source(paste(path_stem, "two_stage.R", sep = ""))
for (k in 1:K) {
# run trial/data set
trial <- one_rep_adaptive(scenario = scenario_num, strong_reg = is_strong, models_list = model_infos,
n_1 = round(new_size/2), n_2_max = new_size - round(new_size/2),
n_2_min = round(new_size*.25),
working_dir = path_stem)
# if the current working directory is not spx_paper_code, supply the path to spx_paper_code
# with the working_dir argument since other paths in the code are relative to it
# save the trial output in the working directory
scenario_name <- Sys.getenv('SLURM_JOB_NAME')
array_task_id <- Sys.getenv('SLURM_ARRAY_TASK_ID')
filename <- paste("trial", array_task_id, k, ".rds", sep = "_")
saveRDS(trial, filename)
}
f <- function(scenario = c(1, 2, 3, 4)) {match.arg(as.character(scenario))}
f(1)
f("1")
f <- function(scenario = c("1", "2", "3", "4")) {match.arg(scenario)}
f("1")
rm(f)
source(paste(path_stem, "two_stage.R", sep = ""))
for (k in 1:K) {
# run trial/data set
trial <- one_rep_adaptive(scenario = scenario_num, strong_reg = is_strong, models_list = model_infos,
n_1 = round(new_size/2), n_2_max = new_size - round(new_size/2),
n_2_min = round(new_size*.25),
working_dir = path_stem)
# if the current working directory is not spx_paper_code, supply the path to spx_paper_code
# with the working_dir argument since other paths in the code are relative to it
# save the trial output in the working directory
scenario_name <- Sys.getenv('SLURM_JOB_NAME')
array_task_id <- Sys.getenv('SLURM_ARRAY_TASK_ID')
filename <- paste("trial", array_task_id, k, ".rds", sep = "_")
saveRDS(trial, filename)
}
for (k in 1:K) {
# run trial/data set
trial <- one_rep_adaptive(scenario = scenario_num, strong_reg = is_strong, models_list = model_infos,
n_1 = round(new_size/2), n_2_max = new_size - round(new_size/2),
n_2_min = round(new_size*.25),
working_dir = path_stem)
# if the current working directory is not spx_paper_code, supply the path to spx_paper_code
# with the working_dir argument since other paths in the code are relative to it
# save the trial output in the working directory
scenario_name <- Sys.getenv('SLURM_JOB_NAME')
array_task_id <- Sys.getenv('SLURM_ARRAY_TASK_ID')
filename <- paste("trial", array_task_id, k, ".rds", sep = "_")
saveRDS(trial, filename)
}
source(paste(path_stem, "two_stage.R", sep = ""))
# set simulation scenario info
scenario_from_SLURM <- nchar(Sys.getenv('SLURM_JOB_NAME')) > 0
if (scenario_from_SLURM) {     # parse info from SLURM job name
scenario_name <- Sys.getenv('SLURM_JOB_NAME')
scenario_num <- unlist(str_split(scenario_name, "_"))[2]  # assumes format like "scenario_2_low"
scenario_size <- unlist(str_split(scenario_name, "_"))[3]
if (scenario_size == "high") {
new_size <- 150
} else if (scenario_size == "low") {
new_size <- 80
}
is_strong <- str_detect(scenario_name, "strong")
} else {     # otherwise supply scenario info manually
scenario_num <- "1"
new_size <- 80
is_strong <- FALSE
}
# run K data sets in serial (from within a SLURM cluster job)
K <- 3
for (k in 1:K) {
# run trial/data set
trial <- one_rep_adaptive(scenario = scenario_num, strong_reg = is_strong, models_list = model_infos,
n_1 = round(new_size/2), n_2_max = new_size - round(new_size/2),
n_2_min = round(new_size*.25),
working_dir = path_stem)
# if the current working directory is not spx_paper_code, supply the path to spx_paper_code
# with the working_dir argument since other paths in the code are relative to it
# save the trial output in the working directory
scenario_name <- Sys.getenv('SLURM_JOB_NAME')
array_task_id <- Sys.getenv('SLURM_ARRAY_TASK_ID')
filename <- paste("trial", array_task_id, k, ".rds", sep = "_")
saveRDS(trial, filename)
}
source(paste(path_stem, "two_stage.R", sep = ""))
for (k in 1:K) {
# run trial/data set
trial <- one_rep_adaptive(scenario = scenario_num, strong_reg = is_strong, models_list = model_infos,
n_1 = round(new_size/2), n_2_max = new_size - round(new_size/2),
n_2_min = round(new_size*.25),
working_dir = path_stem)
# if the current working directory is not spx_paper_code, supply the path to spx_paper_code
# with the working_dir argument since other paths in the code are relative to it
# save the trial output in the working directory
scenario_name <- Sys.getenv('SLURM_JOB_NAME')
array_task_id <- Sys.getenv('SLURM_ARRAY_TASK_ID')
filename <- paste("trial", array_task_id, k, ".rds", sep = "_")
saveRDS(trial, filename)
}
source(paste(path_stem, "two_stage.R", sep = ""))
# run trial/data set
trial <- one_rep_adaptive(scenario = 2, strong_reg = is_strong, models_list = model_infos,
n_1 = round(new_size/2), n_2_max = new_size - round(new_size/2),
n_2_min = round(new_size*.25),
working_dir = path_stem)
3 %in% c("1", "2", "3")
3 == "3"
identical(1, "1")
source(paste(path_stem, "two_stage.R", sep = ""))
# run trial/data set
trial <- one_rep_adaptive(scenario = 2, strong_reg = is_strong, models_list = model_infos,
n_1 = round(new_size/2), n_2_max = new_size - round(new_size/2),
n_2_min = round(new_size*.25),
working_dir = path_stem)
for (k in 1:K) {
# run trial/data set
trial <- one_rep_adaptive(scenario = scenario_num, strong_reg = is_strong, models_list = model_infos,
n_1 = round(new_size/2), n_2_max = new_size - round(new_size/2),
n_2_min = round(new_size*.25),
working_dir = path_stem)
# if the current working directory is not spx_paper_code, supply the path to spx_paper_code
# with the working_dir argument since other paths in the code are relative to it
# save the trial output in the working directory
scenario_name <- Sys.getenv('SLURM_JOB_NAME')
array_task_id <- Sys.getenv('SLURM_ARRAY_TASK_ID')
filename <- paste("trial", array_task_id, k, ".rds", sep = "_")
saveRDS(trial, filename)
}
